export function Inject(token: string) {
    return function (target: Function, name: string, descriptor: number) {
        if(target.prototype['__parameters__'] == undefined) {
            Object.defineProperty(target.prototype, '__parameters__', {
                enumerable: false,
                value: []
            });
        }
        target.prototype['__parameters__'][descriptor] = {token: token};
    }
}
export function InjectByName(token: string) {
    return function (target: Function, name: string, descriptor: number) {
        if(target.prototype['__parameters__'] == undefined) {
            Object.defineProperty(target.prototype, '__parameters__', {
                enumerable: false,
                value: []
            });
        }
        target.prototype['__parameters__'][descriptor] = {token: token};
    }
}

export function InjectFactory() {
    return function (target: Function, name: string, descriptor: number) {
        if(target.prototype['__parameters__'] == undefined) {
            Object.defineProperty(target.prototype, '__parameters__', {
                enumerable: false,
                value: []
            });
        }
        target.prototype['__parameters__'][descriptor] = {token: 'factory'};
    }
}

export type TFactory<T =  any> = (args: {new (...x: any[]):T}) => T;

export function Injectable(injectName?: string, isSingle = false) {
    return function(target: any) {
        if(injectName && typeof injectName === 'string' && injectName.length > 0) {
            target.injectName = injectName;
        }
    }
}
export function PluginInjectable(pluginName: string) {
    return function(target: any) {
        if(pluginName && typeof pluginName === 'string' && pluginName.length > 0) {
            target.pluginName = pluginName;
        }
    }
} 